package com.bkitmobile.kesu.appengine.web.client.Listener;

import com.bkitmobile.kesu.appengine.web.client.GreetingService;
import com.bkitmobile.kesu.appengine.web.client.GreetingServiceAsync;
import com.bkitmobile.kesu.appengine.web.client.utility.LogoutListenerConstant;
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.ClickListener;
import com.google.gwt.user.client.ui.Widget;

public class LogOutListener implements ClickListener {

	private final GreetingServiceAsync greetingService = GWT
		.create(GreetingService.class);
	@Override
	public void onClick(Widget sender) {
		// TODO Auto-generated method stub
		if (Window.confirm(LogoutListenerConstant.wanring_text))
		{
			greetingService.doLogout("", new AsyncCallback<String>() {
			
			@Override
			
			public void onSuccess(String result) {
				// TODO Auto-generated method stub
				Window.Location.reload();
			}
			
			@Override
			public void onFailure(Throwable caught) {
				// TODO Auto-generated method stub
				
			}
		
			});
		}
	}

}
